package com.hsogoo.study.spring.propertysource;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;

import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePropertySource;

/**
 * Created by za-huangsaigang on 2018/9/17.
 */
public class ResourcePropertySourceTest {

    @Test
    public void testResourcePropertySource() throws Exception{

        Resource resource = new ClassPathResource("application.properties");

        ResourcePropertySource source = new ResourcePropertySource("name", resource);

        System.out.println(source.getProperty("name"));
        System.out.println(source.getProperty("age"));
        for(String s : source.getPropertyNames()){
            System.out.println("property:" + s);
        }
        System.out.println(source.containsProperty("name"));
        System.out.println(source.containsProperty("age"));
        System.out.println(source.getName());
        System.out.println(source.getSource());
    }
}
